package com.source.baseData.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.source.baseData.entity.BarcodeMachine;
import com.source.baseData.vo.BarcodeMachineVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author fengq
 * @since 2021-02-06
 */
@Repository
public interface BarcodeMachineMapper extends BaseMapper<BarcodeMachine> {


    /**
     * getOneVoById 根据参数获取BarcodeMachineVo
     * @param barcodeMachineId
     * @return
     */
    @Select("select barcodeMachineId, barcodeMachineNumber,productDate,msg,image,`status` from barcode_machine " +
            "where isDelete=0 " +
            "and barcodeMachineId=${barcodeMachineId}")
    BarcodeMachineVo getOneVoById(@Param("barcodeMachineId") String barcodeMachineId);

    /**
     * getPageVo 获取记录的分页
     * @param page
     * @return
     */
    @Select("select barcodeMachineId, barcodeMachineNumber,productDate,msg,image,`status` from barcode_machine where isDelete=0")
    IPage<BarcodeMachineVo> getPageVo(Page<BarcodeMachineVo> page);

    @Select("Select * from barcode_machine bm where concat_ws(',',barcodeMachineNumber, price, tradeDate, productDate) " +
            "like #{s} AND bm.isDelete = 0  ")
    List<BarcodeMachine> getPageByLike(String s);

    @Select("Select * from barcode_machine bm where bm.barcodeMachineNumber = #{machineNumber} AND bm.isDelete = 0  ")
    BarcodeMachine findByMachineNumber(String machineNumber);

    @Select("SELECT * from barcode_machine bm where bm.houseGrantId IS NULL AND bm.isDelete = 0 ")
    List<BarcodeMachine> findUnGranted();



}
